//package com.ctz.commonframe.network;
//
//import com.ctz.commonframe.utils.Logger;
//
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.Map;
//
//import okhttp3.Interceptor;
//import okhttp3.Request;
//import okhttp3.Response;
//
///*
// * 拦截器
// *
// * 向请求头里添加公共参数
// */
//public class HttpHeaderInterceptor implements Interceptor {
//    private static final String TAG = "HttpHeaderInterceptor";
//    private Map<String, String> mHeaderParamsMap = new HashMap<>();
//
//    @Override
//    public Response intercept(Interceptor.Chain chain) throws IOException {
//        Logger.e(TAG, "add http header params");
//        Request oldRequest = chain.request();
//        // 新的请求
//        Request.Builder requestBuilder =  oldRequest.newBuilder();
//        requestBuilder.method(oldRequest.method(), oldRequest.body());
//
//        //添加公共参数,添加到header中
//        if(mHeaderParamsMap.size() > 0){
//            for(Map.Entry<String,String> params: mHeaderParamsMap.entrySet()){
//                requestBuilder.header(params.getKey(), params.getValue());
//            }
//        }
//        Request newRequest = requestBuilder.build();
//        return chain.proceed(newRequest);
//    }
//
//    public static class Builder{
//        HttpHeaderInterceptor mHttpHeaderInterceptor;
//        public Builder(){
//            mHttpHeaderInterceptor = new HttpHeaderInterceptor();
//        }
//
//        public Builder addHeaderParams(Map<String, String> headerParamsMap) {
//            mHttpHeaderInterceptor.mHeaderParamsMap.putAll(headerParamsMap);
//            return this;
//        }
//
//        public Builder addHeaderParam(String key, String value){
//            mHttpHeaderInterceptor.mHeaderParamsMap.put(key, value);
//            return this;
//        }
//
//        public Builder addHeaderParam(String key, int value){
//            return addHeaderParam(key, String.valueOf(value));
//        }
//
//        public Builder addHeaderParam(String key, float value){
//            return addHeaderParam(key, String.valueOf(value));
//        }
//
//        public Builder addHeaderParam(String key, long value){
//            return addHeaderParam(key, String.valueOf(value));
//        }
//
//        public Builder addHeaderParams(String key, double value){
//            return addHeaderParam(key, String.valueOf(value));
//        }
//
//        public HttpHeaderInterceptor build(){
//            return mHttpHeaderInterceptor;
//        }
//    }
//}
